<link rel="stylesheet" type="text/css" href="../addons/jy_weishop/custom/templates/mobile/css/coupon.css?v=2.0.0">
<link rel="stylesheet" type="text/css" href="../addons/jy_weishop/custom/templates/mobile/css/coupon-new.css?v=2018030302">
<style type="text/css">
.order-create-page .buybtn{width:5rem;margin:0;float:right;}
    .yen{border:none;height:0.75rem;width:0.75rem;display: inline-block;background: #ff4753;color:#fff;font-size:0.4rem;line-height: 0.8rem;text-align: center;
        font-style: normal;border-radius: 0.75rem;-webkit-border-radius: 0.75rem;}
    .order-create-page .fui-list.goods-item .fui-list-inner{
        height: 3.5rem;
        align-self: center;
    }
    .order-create-page .fui-list.goods-item .fui-list-angle{
        height: 3.5rem;
        align-self: center;
    }
    .order-create-page .fui-list-inner .subtitle{
        display: block;
    }
    .fui-header a.back2:before {

        content: " ";

        display: inline-block;

        -webkit-transform: rotate(45deg);

        -ms-transform: rotate(45deg);

        transform: rotate(45deg);

        height: 0.5rem;

        width: 0.5rem;

        border-width: 0 0 2px 2px;

        border-color: #666;

        border-style: solid;

        position: relative;

        top:0;

    }

</style>
<form name='form' action="" method="post">
    <div class='fui-page order-create-page'>
        <div class="fui-header">
            <div class="fui-header-left">
                <a class="back" ng-click="goback()"></a>
            </div>
            <div class="title">确认订单</div>
            <div class="fui-header-right">&nbsp;</div>
        </div>
        <div class='fui-content' style="padding-bottom: 2.5rem;overflow: scroll;overflow-scrolling: touch;">
		<!--判断是否展示地址（不展示条件：开启团长收货，非团长 -->
			<div ng-if="pagedata.item.sendtype==1" class="fui-cell-group fui-cell-click">
			<div id="addressInfo" class="fui-cell-group fui-address-group" style="margin-top:0px">
				<div ng-if="pagedata.item.addressid" class="fui-cell">
					<div style="width:100%">
						<div class="fui-cell-text name bold" style="font-size:0.8rem">
							<span style="margin-right:20px">{{pagedata.item.address.name}}</span><span>{{pagedata.item.address.mobile}}</span>
						</div>
						<div class="fui-cell-text name" style="margin-top:5px">
							<!--预售完成-->
							<i class="fui-tag fui-tag-red">默认</i>
							<i class="fui-tag fui-tag-blue">家</i>
							{{pagedata.item.address.pcd.province+pagedata.item.address.pcd.city+pagedata.item.address.pcd.district+pagedata.item.address.address}}
						</div>
					</div>
					<div class="fui-cell-remark" ng-click="pagedata.get_addresslist()"></div>
				</div>
				<div ng-if="!pagedata.item.addressid" class="fui-list">
					<div class="fui-list-inner" ng-click="pagedata.edit_address=1">
							<div class="text no-address" ><i class="icon jinyunicon icon-tianjia"></i> 添加收货地址</div>
					</div>
				</div>
			</div>               
            </div>
		<div ng-show="pagedata.item.sendtype==2">
			<div class="fui-list-group"  id="carrierInfo" style="display: none;margin: 0 0 0.5rem">
						<a class="fui-list" href="javascript:;" >
							<div class="fui-list-media" style="display: none">
								<i class="icon icon-dingwei"></i>
							</div>
							<div class="fui-list-inner">
								<div class="no-address"><i class="icon icon-icon02"></i> 请选择自提门店</div>
								<div class="subtitle" style="display: none">
									<span style="overflow: hidden;display: inline-block;">联系人：</span>
									<span class='realname'></span>
									<span class='mobile' id="carrierInfo_mobile"></span>
								</div>
								<div class="text" style="display: none"><span class='address'>地址：</span></div>

							</div>
							<div class="fui-list-angle">
								<div class="angle"></div>
							</div>
						</a>
			</div>
			<div class="fui-cell-group sm" id="memberInfo">
					<div class="fui-cell">
						<div class="fui-cell-label sm">联系人</div>
						<div class="fui-cell-info c000"><input type="text" placeholder="请输入联系人" class="fui-input" ng-model="pagedata.post.realname"/></div>
					</div>
					<div class="fui-cell">
						<div class="fui-cell-label sm">联系电话</div>
						<div class="fui-cell-info c000"><input type="tel" placeholder="请输入联系电话"  class="fui-input" ng-model="pagedata.post.mobile"/></div>
					</div>
			</div>
		</div>
       <!-- 联系填写-->
        <div class="fui-list-group" style='margin-top: 10px'>
            <div class="fui-list goods-item">
                <div class="fui-list-media">
                    <a href="javascript:;" ng-click="access_json('jy_aligroup/goods//id='+pagedata.goods.id)" class="external">
                        <img src="{{tomedia(pagedata.goods.image)}}" alt="{{pagedata.goods.title}}" class="round">
                    </a>
                </div>
                <div class="fui-list-inner">
                    <a href="javascript:;" ng-click="access_json('jy_aligroup/goods//id='+pagedata.goods.id)">
                        <div class="text">
                            <span ng-if="!pagedata.goods.isnodiscount && !pagedata.goods.dflag" class='fui-label fui-label-danger'>折扣</span>
                            {{pagedata.goods.title}}
                        </div>
                    </a>
                    <div class="text">
                        <span class="price">数量：1</span>
                        <span class="total">
                            （<span class='text-danger'>¥{{ifelse(pagedata.is_team,pagedata.goods.groupsprice,pagedata.goods.singleprice)}} </span>/{{ifelse(pagedata.goods.units,pagedata.goods.goodsnum+pagedata.goods.units,'件')}}）
                        </span>
                        <div style="clear:both;"></div>
                        
                        <span ng-if="pagedata.goods.showstock>0" class="price ">库存：<span class='marketprice'>{{pagedata.goods.stock || '0'}}</span></span>
                        
                    </div>
                </div>
            </div>
            <div class='fui-cell-group' style="display: none;">
                <div class="fui-cell">
                    <div class="fui-cell-info" style="text-align: right;">
                        <!--共 <span id='goodscount' class='text-danger'>{$total}</span> 件商品-->
                        总价：<span class="text-danger">¥ <span class='goodsprice'>{{pagedata.price}}</span></span>
                    </div>
                </div>
            </div>
        </div>
        <div class="fui-cell-group  sm">
            <div id='coupondiv' ng-if="couponcount>0" class="fui-cell fui-cell-click">
				<div class='fui-cell-label' style='width:auto;'>优惠券</div>
				<div class='fui-cell-info'></div>
				<div class='fui-cell-remark'>
					<div ng-if="pagedata.couponcount<=0" class='badge badge-danger' style='display:none'>{{pagedata.couponcount}}</div>
					<span ng-if="pagedata.couponcount>0" class='text' style='display:none'>无可用</span>
				   
				</div>
			</div>

      
        <div ng-if="pagedata.goods.deduct>0 && pagedata.creditdeduct.creditdeduct>0 && pagedata.member.credit1>0 && pagedata.credit.credit>0&& pagedata.price>0" class="fui-cell">
            <div class="fui-cell-label" style="width: auto;">
                <span id="deductcredit_info" class='text-danger'>{{pagedata.credit.credit}}</span> 积分可抵扣
                <span id="deductcredit_money" class='text-danger'>{{pagedata.credit.deductprice}}</span> 元
            </div>
            <div class="fui-cell-info">
                <input type="hidden" name="credit" value="{$credit['credit']}">
                <input type="hidden" name="creditmoney" value="{$credit['deductprice']}">
                <input type="hidden" id="isdeduct" name="isdeduct" value="0">
                <input id="deductcredit" value="0" data-credit="{$credit['credit']}" data-money="{$credit['deductprice']}" type="checkbox" class="fui-switch fui-switch-small fui-switch-success pull-right">
            </div>
        </div>
    </div>
    <div ng-if="pagedata.stores" class='fui-according-group'>
        <div class='fui-according'>
            <div class='fui-according-header'>
                <i class='icon icon-shop'></i>
                <span class="text">适用门店</span>
                <span class="remark"><div class="badge">{{pagedata.stores.length+1}}</div></span>
            </div>
            <div class="fui-according-content store-container">
                <div ng-repeat="item in pagedata.stores"  class="fui-list store-item">
                    <div class="fui-list-media">
                        <i class='icon icon-shop'></i>
                    </div>
                    <div class="fui-list-inner store-inner">
                        <div class="title"><span class='storename'>{{item.storename}}</span></div>
                        <div class="text">
                            地址: <span class='realname'>{{item.address}}</span>
                        </div>
                        <div class="text">
                            电话: <span class='address'>{{item.tel}}</span>
                        </div>
                    </div>
                    <div class="fui-list-angle ">
                        <a ng-if="item.tel" href="tel:{{item.tel}}" class='external '><i class='icon icon-phone' style='color:green'></i></a>
                    </div>
                </div>
            </div>
            <div id="nearStore" style="display:none">
                <div class='fui-list store-item'  id='nearStoreHtml'></div>
            </div>
        </div>
		</div> 
    <div ng-if="!pagedata.order_formInfo" class="fui-cell-group sm ">
        <div class="fui-cell">
            <div class="fui-cell-info"><input type="text" class="fui-input" name="message" id='remark' placeholder="选填: 买家留言(50字以内)" maxlength="50"></div>
        </div>
    </div>
  
    <div class="fui-cell-group sm">
        <div class="fui-cell">
            <div class="fui-cell-label" >商品小计</div>
            <div class="fui-cell-info"></div>
            <div class="fui-cell-remark noremark">¥ <span class='dispatchprice'>
			    {{ifelse(pagedata.is_team==1,pagedata.goods.groupsprice,pagedata.goods.singleprice)}}
            </span></div>
        </div>
        <div class="fui-cell">
            <div class="fui-cell-label" >运费</div>
            <div class="fui-cell-info"></div>
            <div class="fui-cell-remark noremark">
                ¥ <span class='dispatchprice'>{{pagedata.goods.freight || '0.00'}}</span>
            </div>
        </div>
        <div ng-if="pagedata.heads==1 && pagedata.group.isdiscount==1 && pagedata.goods.headsmoney>0" class="fui-cell">
            <div class="fui-cell-label" style='width:auto' >
                团长优惠 <span ng-if="pagedata.goods.headstype==1" class="text-danger">{{pagedata.goods.headsdiscount / 10}}折</span>
            </div>
            <div class="fui-cell-info"></div>
            <div class="fui-cell-remark noremark">
                - ¥ <span class='isdiscountprice'>
                    {{pagedata.goods.headsmoney}}
                    </span>
            </div>
        </div>
   
        
        <div ng-if="pagedata.isdiscountprice>0" class="fui-cell">
            <div class="fui-cell-label" style='width:auto' >促销优惠</div>
            <div class="fui-cell-info"></div>
            <div class="fui-cell-remark noremark">- ¥ <span class='isdiscountprice'>{{pagedata.isdiscountprice || '0.00'}}</span></div>
        </div>
      
    </div>
</div>
</div>
<div class="fui-navbar order-create-checkout">
	<a ng-if="!pagedata.order_id" ng-click="pagedata.pay()" class="nav-item btn btn-danger confirmbtn">提交（需付：¥ <span class="text-danger totalprice" style="color:#f60">{{pagedata.price+pagedata.goods.freight}}</span>）</a>
	<a ng-if="pagedata.order_id" ng-click="access_json('jy_aligroup/order/')" class="nav-item btn btn-danger confirmbtn">查看订单</a>
</div>
<div id="showstoreitem"  class="modal fade" tabindex="-1" style="z-index:99999;display:none;">
	<div class="modal-dialog" style="width:100%;left:0;bottom:0">
		<div class="modal-bottom">
			<div class="fui-cell-group">
				<div class="fui-cell">
					<div class="fui-cell-label" style="width:100px;font-size:0.9rem">{{pagedata.storeitem.title}}</div>
				</div>
				<div class="fui-cell noborder">
					<div class="fui-cell-label bold" style="width:80px;">地址：</div>
					<div class="fui-cell-info">{{pagedata.storeitem.pcd.province}} {{pagedata.storeitem.pcd.city}} {{pagedata.storeitem.pcd.district}} {{pagedata.storeitem.pcd.street}} {{pagedata.storeitem.address}}</div>
				</div>
				<div class="fui-cell noborder">
					<div class="fui-cell-label bold" style="width:80px;">联系人：</div>
					<div class="fui-cell-info">{{pagedata.storeitem.realname}}</div>
				</div>
				<div class="fui-cell noborder">
					<div class="fui-cell-label bold" style="width:80px;">联系电话：</div>
					<div class="fui-cell-info">{{pagedata.storeitem.mobile}}</div>
				</div>
			</div>
			<div class="fui-navbar" style="padding:0.35rem 1rem">
				<a href="javascript:;"  aria-hidden="true" data-dismiss="modal" class="btn btn-danger btn-banf" style="margin:0;width:100%">关闭</a>
			</div>
		</div>
	</div>
</div>
<div ng-if="pagedata.modal_address==1" class="popup">
	<div class="popup-body">
		<div class="popup-bottom" style="padding-bottom:2.5rem">
		<i class="closed icon icon-close" style="color:red;top:0.3rem" ng-click="pagedata.modal_address=0"></i>
		<div class="fui-list-group modal-swiper-y" style='margin-top:5px;background:#fff;'>
			<div class="fui-list address-item" ng-repeat="item in pagedata.address_list">
				<div class="fui-list-inner">
					<div class="title" ng-click="pagedata.change_address(item)"><span class='realname'>{{item.name}}</span> <span class='mobile'>{{item.mobile}}</span></div>
					<div class="text" ng-click="pagedata.change_address(item)"><span class='address'>{{item.pcd.province}} {{item.pcd.city}} {{item.pcd.district}} {{item.address}}</span></div>
					<div class='bar' style="line-height:1.4">
						<span class='pull-right'>
							<a class="external" href="javascript:;" ng-click="pagedata.item.diyfields=item.diyfields;pagedata.edit_address=1;pagedata.item.address=item;pagedata.isaddaddress=0">
							<i class='icon icon-bianji'></i> 编辑
							</a>
							<a class='external' href="javascript:;" ng-click="pagedata.del_address($index)">
							<i class='icon icon-shanchu'></i> 删除
							</a>
						</span>
						<label class='radio-inline'  ng-click="pagedata.setaddress($index);pagedata.change_address(item)">
							<input type="radio" class="fui-radio  fui-radio-danger" ng-checked="item.isdefault==1"/> 设置默认
						</label>
					</div>
				</div>
			</div>
			<div ng-if="!pagedata.address_list || pagedata.address_list.length<1" class='content-empty' style="margin-top:0">
						<i class='icon icon-map' style="font-size:2rem"></i>
						<div style="padding-bottom:0.5rem">目前没有合适的地址！</div>
			</div>
		</div>
		<div class='fui-navbar' style="padding:0.35rem 1rem">
			<a class="btn btn-danger btn-banf" style="margin:0;width:100%" ng-click="pagedata.item.diyfields=pagedata.addressdiyform;pagedata.edit_address=1;pagedata.post.address.address='';pagedata.isaddaddress=1"><i class="icon icon-tianjia" style="font-size:0.8rem"></i> 添加地址</a>
		</div>
		</div>
	</div>
</div>
<div ng-if="pagedata.edit_address==1" class="popup">
	<div class="popup-body">
		<div class="popup-bottom">
			<div class='fui-cell-group modal-swiper-y' style="border-radius: 0.5rem;margin-top:0;height:auto;max-height:23rem;min-height:20rem;padding-bottom:2.5rem">
				<div class="fui-cell">
					<div class="fui-cell-label" style="width:100px;font-size:0.8rem">编辑地址</div>
					<div class='fui-cell-info' ng-if="pagedata.openid && pagedata.isaddaddress==1 && pagedata.fromh5wxapp!=1"><span class="syscolor" ng-click="pagedata.openAddress()">添加微信地址</span></div>
				</div>
				<div ng-if="!pagedata.item.address.id && pagedata.jy_aiaddress.isopen==1" class="fui-cell">
					<div class="fui-cell-info c000">
						<textarea rows="2" placeholder="请输入要解析的地址" ng-model="pagedata.address.apiaddress"></textarea>
						<div ng-click="pagedata.jieaddress();" class="label label-success" style="position: absolute;right:1rem;bottom:1.3rem">解析地址</div>
					</div>
				</div>
                <div class='fui-cell'>
                    <div class='fui-cell-label'>收件人</div>
                    <div class='fui-cell-info'><input type="text" ng-model="pagedata.item.address.name" placeholder="收件人" class="fui-input"/></div>
                </div>
                <div class='fui-cell'>
                    <div class='fui-cell-label'>联系电话</div>
                    <div class='fui-cell-info'><input type="tel" ng-model="pagedata.item.address.mobile" placeholder="联系电话"  class="fui-input"/></div>
                </div>
                <div class="fui-cell">
					<div class="fui-cell-label" style="width:2.3rem">地区</div>
					<div class="fui-cell-label" style="width:28%">
						<select ng-model="pagedata.item.address.pcd.province" class="form-control tpl-province">
						<option value="" selected="selected">省份</option>
						<option ng-repeat="(value,data) in pagedata.province" value="{{value}}" ng-selected="pagedata.item.address.pcd.province==value">{{value}}</option>
						</select>
					</div>
					<div class="fui-cell-label" style="width:28%">
						<select ng-model="pagedata.item.address.pcd.city" class="form-control tpl-city">
						<option value="" selected="selected">城市</option>
						<option ng-repeat="(value,data) in pagedata.province[pagedata.item.address.pcd.province]" value="{{value}}" ng-selected="pagedata.item.address.pcd.city==value">{{value}}</option>
						</select>
					</div>
					<div class="fui-cell-label" style="width:28%">
						<select ng-model="pagedata.item.address.pcd.district" class="form-control tpl-district">
						<option value="" selected="selected">区县</option>
						<option ng-repeat="(value,data) in pagedata.province[pagedata.item.address.pcd.province][pagedata.item.address.pcd.city]" value="{{value}}" ng-selected="pagedata.item.address.pcd.district==value">{{value}}</option>
						</select>
					</div>
					<div class="fui-cell-label" style="width:28%">
						<select ng-model="pagedata.item.address.pcd.street" class="form-control tpl-district">
						<option value="" selected="selected">街道</option>
						<option ng-repeat="value in pagedata.province[pagedata.item.address.pcd.province][pagedata.item.address.pcd.city][pagedata.item.address.pcd.district]" value="{{value}}" ng-selected="pagedata.item.address.pcd.street==value">{{value}}</option>
						</select>
					</div>
				</div>
                <div class='fui-cell'>
                    <div class='fui-cell-label'>详细地址</div>
					 <div class='fui-cell-info'>
						<textarea rows="2" placeholder="街道，楼牌号等" ng-model="pagedata.item.address.address"></textarea>
					</div>
                </div>
				<div ng-include="sys_html('common/_diyform_item',true)"></div>
            </div>
			<div class="fui-navbar" style="padding:0.35rem 1rem">
				<a href="javascript:;" ng-click="pagedata.add_address();" class="btn btn-danger btn-banf" style="margin:0;width:100%">确定</a>
			</div>
			<i ng-click="pagedata.edit_address=0" class="closed icon icon-cuowu"></i>
		</div>
	</div>
</div>
</form>
<script>
scope.pagedata.pay=function(){
	scope.pagedata.post.aid=scope.pagedata.item.addressid;
	scope.post_json('submit',scope.pagedata.post,function(result){
		scope.pagedata.order_id=result.order_id;
		scope.$evalAsync();
		scope.tool.pay(result.pay_id,function(res){
				if(res.type=='success'){
					scope.message('支付成功！','success','jy_aligroup/order//status=1');
				}else{
					scope.message('支付失败！','success','jy_aligroup/order//status=0');
				}
		},'','','jy_aligroup/order/');
	});
}
scope.pagedata.change_address=function(res){
	console.log(res);
	scope.pagedata.item.address=res;
	scope.pagedata.item.addressid=res.id;
	scope.pagedata.modal_address=0;
	scope.$evalAsync();
}

scope.pagedata.setaddress=function(index){
	var id =scope.pagedata.address_list[index].id
	scope.get('core/member.address/set/id='+id+'&get=1',function(res){
		for(var i in scope.pagedata.address_list){
				scope.pagedata.address_list[i].isdefault=0
		}
		scope.pagedata.address_list[index].isdefault=1
		scope.pagedata.item.addressid=id
		scope.pagedata.modal_address=0;
		scope.message('设置成功');
		scope.$evalAsync();
	});
}
scope.pagedata.del_address=function(index){
	var id =scope.pagedata.address_list[index].id
	scope.get('core/member.address/del/id='+id+'&get=1',function(res){
		scope.pagedata.address_list.splice(index,1);
		scope.message('删除成功');
		scope.$evalAsync();
	});
}
scope.pagedata.get_addresslist=function(){
	scope.pagedata.item.address.res=1
	scope.get('jy_weishop/get_data/get_addresslist/',function(res){
		scope.pagedata.address_list=res.list;
		scope.pagedata.modal_address=1;
		scope.$evalAsync();	
	});
}
scope.pagedata.add_address=function(){
	scope.pagedata.item.address.res=1
	if(scope.pagedata.isaddaddress==1){
		scope.pagedata.item.address.id=0;
	}
	scope.pagedata.item.address=scope.pagedata.item.address;
	scope.pagedata.item.address.diyfields=scope.pagedata.item.diyfields;
	scope.post_json('core/member.address/post/',scope.pagedata.item.address,function(res){
			scope.pagedata.item.addressid =res;
			scope.pagedata.edit_address=0;
			scope.$evalAsync();	
	});
}
scope.pagedata.getprovince=function(){
	scope.get('jy_weishop/get_data/getprovince/',function(res){
		scope.pagedata.province=res.province;
		scope.$evalAsync();
	});
}
scope.pagedata.getprovince();
</script>

